# -*- coding: utf-8 -*-            
# @Author : HJH
# @Time : 2024/1/22 14:58
# @Use : 携程特殊政策新增请求
from datetime import datetime


class UserToken:
    def __init__(self,
                 UserName: int = None,
                 Password: int = None):
        """
        用户信息
        :param UserName: 用户名	string	是
        :param Password: 密码	String	否	MD5(UTF8(name#password))
        """
        self.UserName = UserName,
        self.Password = Password


class MessageHead:
    def __init__(self,
                 UserInfo: UserToken = None,
                 RequestGUID: int = None):
        """
        请求头部信息
        :param UserInfo: 用户信息	UserTokenType	是
        :param RequestGUID: 请求GUID	string	否	新增操作时为必传
        """
        self.UserInfo = UserInfo,
        self.RequestGUID = RequestGUID


class MessageBody:
    def __init__(self,
                 PolicyList: list = None):
        """
        请求头部信息
        :param PolicyList: 新增政策列表	SpecialPolicyDetailType	是
        """
        self.PolicyList = PolicyList


class Summary:
    def __init__(self,
                 Class: int = None,
                 AdvanceDay: int = None,
                 MaxAdvanceDay: int = None,
                 PolicyCode: int = None,
                 AirLine: int = None,
                 FlightWay: int = None,
                 ApplyChild: int = None,
                 OfficeNo: int = None,
                 DepartPort: int = None,
                 ArrivePort: int = None,
                 EffectDate: datetime = None,
                 ExpiryDate: datetime = None,
                 MinStopDay: int = None,
                 MaxStopDay: int = None,
                 IsValid: int = None,
                 ProductType: int = None,
                 IsSecurity: int = None,
                 ApplyFlag: int = None,
                 NeedPATA: int = None,
                 BatchNo: int = None,
                 TicketRemark: int = None,
                 IsAutoTicket: int = None,
                 IsShareFlight: int = None,
                 CreatorID: int = None,
                 IATANo: int = None,
                 RcID: int = None,
                 IsValidCarrierAirline: int = None):
        """
        概要信息
        :param Class: 舱位等级	ServiceLevelType	是	F：头等舱 C:公务舱  Y:经济舱
        :param AdvanceDay: 提前预订天数	int	是	取值0-365，不能大于 MaxAdvanceDay
        :param MaxAdvanceDay: 最大提前预订天数	int	是	取值0-365，为0表示禁止销售
        :param PolicyCode: 政策代码	String	否
        :param AirLine: 航空公司	CarrierCodeType	是
        :param FlightWay: 航程类型	FlightWayType	是	单程（S)，往返（D）
        :param ApplyChild: 儿童是否适用	IsValidType	是	T-是F-否
        :param OfficeNo: 授权Office号	string	否
        :param DepartPort: 始发机场代码	AirPortCodeType	是
        :param ArrivePort: 到达机场代码	AirPortCodeType	是
        :param EffectDate: 销售日期起	dateTime	是	精确到日期，时间部分将被截断
        :param ExpiryDate: 销售日期止 dateTime	是	精确到日期，时间部分将被截断
        :param MinStopDay: 最小停留天数	int	是	航程类型为往返时生效
        :param MaxStopDay: 最大停留天数	int	是	航程类型为往返时生效
        :param IsValid:     IsValidType	是	T-是F-否
        :param ProductType: 产品类型	PolicyProductType	是	0：ALL全部
                                                            1：NFD普通
                                                            2：ZZMP清仓产品(原占座免票)
                                                            3：DKHXY商旅产品(原大客户协议)
                                                            4：ZZ中转
                                                            5：ZZQC中转产品(原中转弃程)
                                                            6：BJ包机
                                                            7：QW切位
                                                            8：HSVIP航司VIP
                                                            9：OTHER其他(已经废弃)
                                                            10：TJ特价
        :param IsSecurity: 是否惠选	IsValidType	否	T:是F:否已废弃
        :param ApplyFlag: 是否申请	ApplyFlagType	否	NA:不需申请
                                    AgencyPolicy:合作票台申请
                                    WaitingPolicy:候补
                                    RefundPolicy:退废票转申请
                                    HoardingPolicy:囤票申请
        :param NeedPATA: 是否PATA	IsValidType	否	T-是F-否
        :param BatchNo: 批次号	String	否
        :param TicketRemark: 出票备注	String	否
        :param IsAutoTicket: 是否自动出票	IsValidType	否	T-是F-否
        :param IsShareFlight: 是否共享航班	IsValidType	否	T-是F-否
        :param CreatorID: 政策创建者的用户ID	int	否
        :param IATANo: IATA号	string	否
        :param IsValidCarrierAirline: 共享航班是否对承运航司验证舱验价	IsValidType	否
        """
        self.RcID = RcID
        self.Class = Class
        self.AdvanceDay = AdvanceDay
        self.MaxAdvanceDay = MaxAdvanceDay
        self.PolicyCode = PolicyCode
        self.AirLine = AirLine
        self.FlightWay = FlightWay
        self.ApplyChild = ApplyChild
        self.OfficeNo = OfficeNo
        self.DepartPort = DepartPort
        self.ArrivePort = ArrivePort
        self.EffectDate = EffectDate
        self.ExpiryDate = ExpiryDate
        self.MinStopDay = MinStopDay
        self.MaxStopDay = MaxStopDay
        self.IsValid = IsValid
        self.ProductType = ProductType
        self.IsSecurity = IsSecurity
        self.ApplyFlag = ApplyFlag
        self.NeedPATA = NeedPATA
        self.BatchNo = BatchNo
        self.TicketRemark = TicketRemark
        self.IsAutoTicket = IsAutoTicket
        self.IsShareFlight = IsShareFlight
        self.CreatorID = CreatorID
        self.IATANo = IATANo
        self.IsValidCarrierAirline = IsValidCarrierAirline


class FIX:
    def __init__(self,
                 TicketInventory: int = None):
        """
        FIX模式参数
        :param TicketInventory: 可售座位数	int	是	可售座位数(总数）
        """
        self.TicketInventory = TicketInventory


class Inventory:
    def __init__(self,
                 InventoryType: int = None,
                 IsBooking: int = None,
                 # FIX: FIX = None,
                 BookingThreshold: int = None,
                 BookingType: int = None,
                 IsReturnRefundInventory: int = None,
                 IsShortageFilter: int = None,
                 ShortageFilterCount: int = None):
        """
        库存信息
        :param InventoryType: 库存查询模式	InventoryTypeType	是	FAV-见舱 FIX-定额
        :param IsBooking: 是否订位	IsValidType	是	T-是F-否
        :param FIX: FIX模式参数		否	FIX模式时必选，FAV模式可选
        :param BookingThreshold: 紧张订位阈值	Int	否	外放舱位数量小于等于阈值时订位
        :param BookingType: 订位方式 	BookingTypeType	否	0未知
                                                            1不定位
                                                            2自动订位
                                                            3人工订位
        :param IsReturnRefundInventory: 退票是否还库存	IsValidType	否	T-是F-否
        :param IsShortageFilter: 是否紧张位置过滤	string	是	T-是F-否
        :param ShortageFilterCount: 紧张过滤阈值	int	否
        """
        self.InventoryType = InventoryType
        self.IsBooking = IsBooking
        # self.FIX = FIX
        self.BookingThreshold = BookingThreshold
        self.BookingType = BookingType
        self.IsReturnRefundInventory = IsReturnRefundInventory
        self.IsShortageFilter = IsShortageFilter
        self.ShortageFilterCount = ShortageFilterCount


class Flight:
    def __init__(self,
                 EffectDate: datetime = None,
                 ExpiryDate: datetime = None,
                 Days: int = None,
                 SubClass: int = None,
                 IsCanSale: int = None,
                 RuleDetail: int = None):
        """
        航班信息
        :param EffectDate: 航班日期起	dateTime	是
        :param ExpiryDate: 航班日期止	dateTime	是
        :param Days: 班期	string	是	周一至周日用1234567表示，可以缺少某几个值，但要保证顺序。比如: 137 2345 1234567
        :param SubClass: 舱位	CabinSubClassType	是
        :param IsCanSale: 是否可售	IsValidType	是	T-是F-否
        :param RuleDetail: 航班号范围	string	否	格式为：100-1120,1130,1140 等，最多100段值为空时表示可售，忽略RuleCanSaleFIX模式只能为单个数值
        """
        self.EffectDate = EffectDate
        self.ExpiryDate = ExpiryDate
        self.Days = Days
        self.SubClass = SubClass
        self.IsCanSale = IsCanSale
        self.RuleDetail = RuleDetail


class Price:
    def __init__(self,
                 PrintPrice: float = None,
                 SalePrice: float = None,
                 SetPrice: float = None,
                 ReturnPrice: float = None,
                 ReturnPoint: float = None,
                 BiddingSpace: float = None,
                 BidType: int = None):
        """
        价格信息
        :param PrintPrice: 票面价	unsignedInt	否
        :param SalePrice: 建议销售价	decimal	否
        :param SetPrice: 结算价	decimal	是
        :param ReturnPrice: 留钱	decimal	是
        :param ReturnPoint: 代理费率	decimal	否	ReturnPoint和SetPrice至少填一项
        :param BiddingSpace: 竞价空间	decimal	否
        :param BidType: 竞价空间类型	UnsignedByte	否	竞价空间类型：0-固定金额 1-按百分比[0,100]
        """
        self.PrintPrice = PrintPrice
        self.SalePrice = SalePrice
        self.SetPrice = SetPrice
        self.ReturnPrice = ReturnPrice
        self.ReturnPoint = ReturnPoint
        self.BiddingSpace = BiddingSpace
        self.BidType = BidType


class RuleRestrict:
    def __init__(self,
                 FeeBasis: int = None,
                 MinFeeExpense: int = None,
                 RefundRateRemarks: int = None,
                 ReroutRateRemarks: int = None,
                 IsEndorse: int = None,
                 Remarks: int = None):
        """
        退改信息
        :param FeeBasis: 退票计算基准	FeeBasisType	是	S-票面价 F-标准价 D-FD价
        :param MinFeeExpense: 最低退票费	int	是
        :param RefundRateRemarks: 退票手续费率	string	是	1）0表示不得退改签
                                                            2）10-2-20，表示起飞前2小时之前的手续费比例是10%，起飞前2小时（含）以内及起飞后的手续费比例是20%；
                                                            3）10-2-20-0-50，表示起飞前2小时之前的手续费比例是10%，起飞前2小时（含）以内收20%，航班起飞后收50%；
                                                            4）10-0-50，表示起飞前收10%，起飞后收50%
                                                            5）50-0-100，表示起飞前收50%，起飞后不得退票；5选1
        :param ReroutRateRemarks: 更改手续费率	string	是	1）0表示不得退改签
                                                            2）10-2-20，表示起飞前2小时之前的手续费比例是10%，起飞前2小时（含）以内及起飞后的手续费比例是20%；
                                                            3）10-2-20-0-50，表示起飞前2小时之前的手续费比例是10%，起飞前2小时（含）以内收20%，航班起飞后收50%；
                                                            4）10-0-50，表示起飞前收10%，起飞后收50%
                                                            5）50-0-100，表示起飞前收50%，起飞后不得退票；5选1
        :param IsEndorse: 允许签转	IsValidType	是	T-是 F-否
        :param Remarks: 备注	string	否
        """
        self.FeeBasis = FeeBasis
        self.MinFeeExpense = MinFeeExpense
        self.RefundRateRemarks = RefundRateRemarks
        self.ReroutRateRemarks = ReroutRateRemarks
        self.IsEndorse = IsEndorse
        self.Remarks = Remarks


class Policy:
    def __init__(self,
                 SummaryUnit: Summary = None,
                 InventoryUnit: Inventory = None,
                 GoFlightUnit: Flight = None,
                 BackFlightUnit: Flight = None,
                 PriceUnit: Price = None,
                 RuleRestrict: RuleRestrict = None):
        """
        政策信息
        :param SummaryUnit: 概要信息	Summary	是
        :param InventoryUnit: 库存信息	Inventory	是
        :param GoFlightUnit: 去程航班	Flight	是
        :param BackFlightUnit: 返程航班	Flight	否
        :param PriceUnit: 身价格信息	Price	是
        :param RuleRestrict: 退改签信息	RuleRestrict	否
        """
        self.SummaryUnit = SummaryUnit
        self.InventoryUnit = InventoryUnit
        self.GoFlightUnit = GoFlightUnit
        self.BackFlightUnit = BackFlightUnit
        self.PriceUnit = PriceUnit
        self.RuleRestrict = RuleRestrict
